<template>
  <div class="cartcontrol">
    <transition name="move">
      <div class="iconfont iconsousuo jianhaomove" v-if="food.count" @click.stop="updateFoodCount(false)"></div>
    </transition>
    <div class="cart-count" v-if="food.count">{{food.count}}</div>
    <div class="iconfont iconuser" @click.stop="updateFoodCount(true)"></div>
  </div>
</template>

<script>
  export default {
    name: "cartControl",
    props:{
      food:Object
    },
    methods:{
      updateFoodCount(isAdd){
        this.$store.dispatch('updataFoodCunt',{isAdd,food:this.food})
      }
    }
  }
</script>

<style lang="stylus" scoped>
  @import "../../common/stylus/mixins.styl"
  .cartcontrol
    font-size:0
    display:flex
    align-items:center
    .jianhaomove
      &.move-enter-active,&.move-leave-active
        transition:0.5s
      &.move-enter,&.move-leave-to
        opacity:0
        transform:translateX(25px) rotate(180deg)
    .iconsousuo
      display: inline-block
      padding: 6px
      line-height:24px
      font-size:24px
      color:rgb(0,160,220)
    .cart-count
      display: inline-block
      vertical-align: top
      width:12px
      padding-top:6px
      line-height:24px
      text-align: center
      font-size:10px
      color:rgb(147,153,159)
    .iconuser
      display: inline-block
      padding:6px
      line-height:24px
      font-size:24px
      color:$green
</style>
